<%--
    Document   : newjsp
    Created on : Jun 23, 2010, 12:16:49 PM
    Author     : zwu
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%!
     Processor.Pair<PrintWriter, Scanner> pair;
    public void jspInit() {

        Repository rep;
        Session jcrSession;
        String exe = this.getServletContext().getRealPath("/") + "WEB-INF/resources/2RTF";
       
        try {
              pair = Processor.processing(new String[]{exe});
            rep = RepositoryAccessServlet.getRepository(getServletContext());
            jcrSession = rep.login(new SimpleCredentials("anonymous", "".toCharArray()));
            ObservationManager observationManager =
                    jcrSession.getWorkspace().getObservationManager();
            observationManager.addEventListener(new MetadataListener(jcrSession, pair,this.getServletContext().getRealPath("/data/"), "http://localhost:9080/ilookinto" ),
                    Event.NODE_ADDED, "/", true, null, new String[]{"nt:file"}, false);
        } catch (Throwable e) {
            e.printStackTrace();
        }

    }

    public void jspDestroy()
            {
            System.out.println("desroy");
             pair.first.write("Q\n");
             pair.first.close();
        }
%>
<%@ page import="javax.jcr.Repository,
         org.apache.jackrabbit.j2ee.RepositoryAccessServlet,
         org.apache.jackrabbit.util.Text,
         javax.jcr.Session,
         javax.jcr.SimpleCredentials,
         javax.jcr.query.Query,
         javax.jcr.query.RowIterator,
         java.text.NumberFormat,
         javax.jcr.query.Row,
         javax.jcr.Node,
         java.net.URLEncoder,
         java.text.SimpleDateFormat,
         java.text.DateFormat,
         java.util.List,
         java.util.ArrayList,
         javax.jcr.observation.Event,
         javax.jcr.observation.EventIterator,
         javax.jcr.observation.EventListener,
         javax.jcr.observation.ObservationManager,
         java.util.Iterator,
         javax.jcr.Value,
         javax.jcr.observation.Event,
         org.ilookinto.doexe.Processor,
         java.io.PrintWriter,
         java.util.Scanner,
         org.ilookinto.jr.MetadataListener,
         javax.jcr.observation.ObservationManager,
         javax.jcr.RepositoryException"%>


